package com.nache.ws;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import android.os.AsyncTask;
import android.util.Log;

public class NetworkCallAsync extends AsyncTask<String, Void, String> {

	@Override
	protected String doInBackground(String... arg0) {
		  StringBuilder response = new StringBuilder();
	         URL url;
			try {
				url = new URL(arg0[0]);
			
	         HttpURLConnection httpconn = (HttpURLConnection) url.openConnection();
	         httpconn.addRequestProperty("accept", "application/json");
	         if (httpconn.getResponseCode() == HttpURLConnection.HTTP_OK) {
	                 BufferedReader input = new BufferedReader(new InputStreamReader(
	                                 httpconn.getInputStream()), 8192);
	                 String strLine = null;
	                 while ((strLine = input.readLine()) != null) {
	                         response.append(strLine);
	                 }
	                 input.close();
	         }
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	         return response.toString();
	}
	protected void onPostExecute(String result) {
        Log.i("Downloaded-rohit ", result );
    }

}
